<?php

use yii\db\Migration;

/**
 * Class m180320_201411_process_instance_top_vo
 */
class m180320_201411_process_instance_top_vo extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {

    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        echo "m180320_201411_process_instance_top_vo cannot be reverted.\n";

        return false;
    }


    // Use up()/down() to run migration code without a transaction.
    public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        }

        $this->createTable('{{%process_instance_top_vo}}', [
            'process_instance_id' => $this->string(200)->notNull(),
            'title' => $this->string(200)->notNull(),
            'create_time' => $this->string(100)->notNull(),
            'finish_time' => $this->string(100)->notNull(),
            'originator_userid' => $this->string(100)->notNull(),
            'originator_dept_id'=>$this->string(50)->notNull(),
            'status' => $this->string(50)->notNull(),
            'approver_userid_list' => $this->text()->notNull(),
            'cc_userid_list' => $this->text()->notNull(),
            'form_component_values' => $this->text()->notNull(),
            'process_instance_result' => $this->string(50)->notNull(),
            'business_id' => $this->string(50)->notNull(),
        ], $tableOptions);

    }

    public function down()
    {
        $this->dropTable('{{%process_instance_top_vo}}');
    }
}
